<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of adaptstats</title>
  <meta name="keywords" content="adaptstats">
  <meta name="description" content="ADAPTSTATS gets the local mean and standard deviations for each pixel in the image within a region.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- # RADOCCToolbox --><!-- menu.html CornerFinder -->
<h1>adaptstats
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>ADAPTSTATS gets the local mean and standard deviations for each pixel in the image within a region.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [mimg,stdv]=adaptstats(img,win) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> ADAPTSTATS gets the local mean and standard deviations for each pixel in the image within a region.
 
 USAGE:
     [mimg,stdv]=adaptstats(img,win);
     [mimg,stdv]=adaptstats(img);
 
 INPUTS:
     img: grayscale image of class double
 
     win: (optional) default value is min(size(img))/5, win is the size of
     the region</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="adaptimadj.html" class="code" title="function imgout=adaptimadj(img,win,th)">adaptimadj</a>	ADAPTIMADJ adaptively adjusts the intensity of an image</li><li><a href="findcorners.html" class="code" title="function imgcout=findcorners(img,debug)">findcorners</a>	FINDCORNERS is the main function called by the calibration GUI.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [mimg,stdv]=adaptstats(img,win)</a>
0002 <span class="comment">% ADAPTSTATS gets the local mean and standard deviations for each pixel in the image within a region.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% USAGE:</span>
0005 <span class="comment">%     [mimg,stdv]=adaptstats(img,win);</span>
0006 <span class="comment">%     [mimg,stdv]=adaptstats(img);</span>
0007 <span class="comment">%</span>
0008 <span class="comment">% INPUTS:</span>
0009 <span class="comment">%     img: grayscale image of class double</span>
0010 <span class="comment">%</span>
0011 <span class="comment">%     win: (optional) default value is min(size(img))/5, win is the size of</span>
0012 <span class="comment">%     the region</span>
0013 
0014 <span class="comment">%Check input</span>
0015 <span class="keyword">if</span> ~exist(<span class="string">'win'</span>,<span class="string">'var'</span>) || isempty(win)
0016     <span class="comment">% default win size</span>
0017     win=round(min(size(img))/5);
0018 <span class="keyword">end</span>
0019 
0020 <span class="comment">% create integral image, integral image allows for quicker execution time</span>
0021 <span class="comment">% for large window sizes.</span>
0022 intimg = cumsum(cumsum(img),2);
0023 intimg2 = cumsum(cumsum(img.^2),2);
0024 
0025 hwin=floor(win/2);
0026 
0027 <span class="comment">% pad integral images</span>
0028 
0029 intimg=padarray(intimg,[hwin+1,hwin+1],<span class="string">'pre'</span>);
0030 intimg=padarray(intimg,[hwin,hwin],<span class="string">'post'</span>,<span class="string">'replicate'</span>);
0031 intimg2=padarray(intimg2,[hwin+1,hwin+1],<span class="string">'pre'</span>);
0032 intimg2=padarray(intimg2,[hwin,hwin],<span class="string">'post'</span>,<span class="string">'replicate'</span>);
0033 
0034 <span class="comment">% get mean and stdv images</span>
0035 simg=intimg(1:size(img,1),1:size(img,2))+intimg(win+1:size(img,1)+win,win+1:size(img,2)+win)<span class="keyword">...</span>
0036     -intimg(1:size(img,1),win+1:size(img,2)+win)-intimg(win+1:size(img,1)+win,1:size(img,2));
0037 simg2=intimg2(1:size(img,1),1:size(img,2))+intimg2(win+1:size(img,1)+win,win+1:size(img,2)+win)<span class="keyword">...</span>
0038     -intimg2(1:size(img,1),win+1:size(img,2)+win)-intimg2(win+1:size(img,1)+win,1:size(img,2));
0039 
0040 n=win^2;
0041 mimg=simg/n;
0042 vari=(simg2-(mimg.^2)*n)/(n-1);
0043 stdv=sqrt(vari);</pre></div>
<hr><address>Generated on Sun 04-Apr-2010 17:13:59 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>